Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify RuntimeContainer #178

Merged
merged 1 commit into from
Jul 17, 2023
Merged

Simplify RuntimeContainer #178

merged 1 commit into from
Jul 17, 2023

Conversation

adamlogic
Copy link
Collaborator

We have no use for service_name, so we can treat the runtime container as just the container ID. This also preps us for ECS, where we don't have access to the service name.

@adamlogic adamlogic requested a review from jon-sully July 14, 2023 18:03
Copy link
Member

@jon-sully jon-sully left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I like this. A bit of a mental trip to change over and think of RuntimeContainer as actually just a string with an extra method (so RuntimeContainer.new is really just String.new) but I think it's clever!

Comment on lines +14 to +15
instance_number = split(".")[1].to_i
instance_number > 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this working off the basis that nil.to_i is 0? 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever 😁

@api_base_url ||= "https://adapter.judoscale.com/api/#{ENV["RENDER_SERVICE_ID"]}"
elsif ENV["DYNO"]
service_name, instance = ENV["DYNO"].split "."
@current_runtime_container = RuntimeContainer.new service_name, instance
@current_runtime_container = RuntimeContainer.new ENV["DYNO"]
else
# unsupported platform? Don't want to leave @current_runtime_container nil though
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to drop this comment now 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it no longer valid? I still found it helpful, assuming we don't want @current_runtime_container to be nil.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't, but the "unsupported platform" bit isn't a valid assumption anymore, now that we know there are platforms which the correct functionality is to have the bare RuntimeContainer.new 🤔 so maybe just the first 2 words of the comment 😆

We have no use for `service_name`, so we can treat the runtime container as just the container ID.
@adamlogic adamlogic force-pushed the am-simplify-runtime-container branch from be6aeda to 4563363 Compare July 17, 2023 12:40
@adamlogic adamlogic merged commit 4072a51 into main Jul 17, 2023
51 checks passed
@adamlogic adamlogic deleted the am-simplify-runtime-container branch July 17, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants